package crawler;

public class Controller implements Runnable {
	
	private CTSPipe cts;
	private STCPipe stc;
	private NVQueue<String> pendingWebs;
	
	private boolean eoe;
	
	public Controller(CTSPipe _cts, STCPipe _stc) {
		cts = _cts;
		stc = _stc;
		pendingWebs = new NVQueue<String>();
//		pendingWebs.push("http://google.com");
		eoe = false;
		
	}
	
	public void run() {

		while (!eoe) {
			

			if (stc.getRequest()) {
				//System.out.println("enviando direcciones");
				stc.sendPendindgWebs(pendingWebs);
			}
			
			if (pendingWebs.size() == 0) {
				System.out.println("El servidor no tiene direcciones");
				pendingWebs.join(cts.receivePendingWebs());
				pendingWebs.mostrar("Webs que recibe el servidor");
			}
			//if (pendingWebs.size() > 10)
			//System.out.println(pendingWebs.size());
			//pendingWebs.mostrar("Lista de webs del servidor");
			
		
		}
	}
	
	

}
